#include<allegro.h>
#include "explosion.h"


void load_background(BITMAP *bg)

{
bg=load_bitmap("bar.bmp",NULL);
}
//chargement du bar

void load_peter(BITMAP *img)

{
img=load_bitmap("derriere.bmp",NULL);
}
//chargement d peter

void load_alex(BITMAP *img1)

{
 img1=load_bitmap("alex0.bmp",NULL);
}
//chargement d alex

void load_bombe0(BITMAP *img2)

{
 img2=load_bitmap("bombe0.bmp",NULL);
}
//chargement de la bombe

void load_bombe1(BITMAP *img3)

{
 img3=load_bitmap("bombe1.bmp",NULL);
}
//chargement de boom


void draw_bg(BITMAP *bg, BITMAP *buffer)

{
 draw_sprite(buffer,bg,0,0);
}
//copier le bar dans la memoire video en enlevant le rose
void draw_peter( BITMAP *img, BITMAP *buffer)

{
int x=0;
int y=0;
 draw_sprite(buffer,img,x,y);
}
//copier l image dans la mémoire vidéo en enlevant le rose

void draw_alex(BITMAP *img1, BITMAP *buffer)

{
int x1=0;
int y1=0;
 draw_sprite(buffer,img1,x1,y1);
}
//copier alex dans la memoire vidéo en enlevant le rose

void draw_bombe0(BITMAP *img2, BITMAP *buffer)

{
int x2=0;
int y2=0;
 draw_sprite(buffer,img2,x2,y2);
}
//copier la bombe dans la memoire video en enlevant le rose

void draw_bombe1(BITMAP *img3, BITMAP *buffer)

{
int x3=0;
int y3=0;
 draw_sprite(buffer,img3,x3,y3);
}
//copier booom dans la memoire video en enlevant le rose
////////////





void deplacement(BITMAP *bg,BITMAP *img,BITMAP *img1,BITMAP *img2,BITMAP *img3)
{
int x1=0;
int y1=0;
int x=0;
int y=0;
int x2=0;
int y2=0;
int x3=0;
int y3=0;
int b;
int direction;
int life;



  if (key[KEY_RIGHT])
{
    x++;
   
    
}
  if (key[KEY_LEFT])
{
  x--;
  
}
 if (key[KEY_SPACE])
{
x2 = x;
y2 = y;
b = 1;
 

}
 
 if  ((x1  <= SCREEN_W - img1->w) && direction == 1)
{
  x1++;
	if((x1  >= SCREEN_W - img1->w))
        {
		direction =0;	
	}

}
     else
{
	x1--;

   if((x1  <= 100))
        {
		direction =1;	
	}
}
 

 draw_bg(bg, buffer);
 draw_alex(img, buffer);

   if(life == 1)

 draw_bombe0(img1, &buffer);

  if(b==1)
{
   if(y2>=50)
{

  img2=load_bitmap("bombe0.bmp",NULL);
  draw_bombe0(img2, buffer);
  y2--;
}
  else
{

  clear_bitmap(img2);


  load_bombe1(&img3);
  
 
  //usleep(9000);
	y2--;

 if(y2<=20)
{
 clear_bitmap(img3);

   x3 = 50;
  y3 = 500;
}
   else
{
  x3 = x2;
  y3 = 50;

 draw_bombe1(img3, buffer);
}
}

}

  if(x1<= (x3+140) && (x1+140)>x3 && y1>= y3 && y1<=(y3+150))

{

life = 0;
clear_bitmap(img1);
}


blit(buffer,screen,0,0,0,0,SCREEN_W,SCREEN_H);

}
